<?php

if(isset($_GET['term'])) {
    $search = $_GET['term'];
    
    $db = mysql_connect('localhost', 'boughtns_user', 'GodLovesYou!');
    
    if (!$db) {
        die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db('boughtns_mas', $db);
    
    $query = "SELECT * FROM organization where name like '%" . $search . "%' LIMIT 10";
   // echo $query;
    
    $result = mysql_query($query);
    echo mysql_error();
    
    $dataArray = array();
    
    while($row = mysql_fetch_assoc($result)) 
    {
        $id = $row['id'];
        $name = $row['name'];
        $json = new JsonObj;
        $json->id = $id;
        $json->value = $name;
        array_push($dataArray,$json);
    }
    
    
    
    echo json_encode($dataArray);
    
    mysql_close($db);
}



class jsonObj
{
    public $id;
    public $value;
    
}    

?>